﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
//using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Client
{
    public partial class ProgressBar : Form
    {
        #region -  EVENTS  -
        public event FormExitEventHandler OnFormExit = null;
        public event StopSendFileEventHandler OnStopSendFile = null;
        #endregion

        #region -  CONTRUCTOR  -
        public ProgressBar()
        {
            InitializeComponent();
        }
        #endregion

        #region -  SET TITLE  -
        public void SetTitle(string title)
        {
            try
            {
                this.Text = title;
            }
            catch
            {
            }
        }
        #endregion

        #region -  SET MESSAGE  -
        public void SetMessage(string message)
        {
            try
            {
                this.label1.Text = message;
            }
            catch
            {
            }

        }
        #endregion

        #region -  SET VALUE  -
        public void SetProgressBarValue(int percent)
        {
            try
            {
                if (percent < 100)
                {
                    this.progressBar1.Value = percent;
                }
                else
                {
                    this.progressBar1.Value = percent;
                    this.Close();
                }
            }
            catch
            {
            }

        }
        #endregion

        #region -  FORM CLOSED  -
        private void ProgressBar_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (this.OnFormExit != null)
            {
                this.OnFormExit(this, new FormExitEvenArgs());
            }
            if (this.OnStopSendFile != null)
            {
                this.OnStopSendFile(this, new EventArgs());
            }
        }
        #endregion
    }
}
